package com.gs.SynPatrolRep.model;

import com.gs.SynPatrolRep.callback.Callback;
import com.gs.SynPatrolRep.model.listener.OnResultListener;
import com.gs.SynPatrolRep.util.OKHttpUtil;

import java.lang.reflect.Type;

public class PalBillEventModel {
    public void getData(Object bean, final OnResultListener onResultListener, Type typeofT){
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBillEvents", bean,
                new Callback() {
                    @Override
                    public void onSuccess( Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                },typeofT);
    }

    public void create(Object bean, final OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBillEvents/add", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                }, typeofT);
    }


    public void getData(String id, final OnResultListener listener, Type typeofT) {
        OKHttpUtil.getInstance().getAsync(OKHttpUtil.NET_URL + "/api/palBillEvents?id=" + id, new Callback() {
            @Override
            public void onSuccess(Object obj) {
                listener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                listener.onFails(e);
            }
        }, typeofT);
    }

    public void setResult(Object bean, final OnResultListener onResultListener, Type typeofT){
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/palBillEvents/repResult", bean,
                new Callback() {
                    @Override
                    public void onSuccess(Object obj) {
                        onResultListener.onSuccess(obj);
                    }

                    @Override
                    public void onFailed(Exception e) {
                        onResultListener.onFails(e);
                    }
                },typeofT);
    }
}
